#pragma once
#include "HashTable.h"
namespace lw
{
	template<class K, class V, class Hash = HashFunc<K>>
	class unordered_map
	{
		struct MapKeyOfT
		{
			const K& operator()(const pair<const K, V>& kv)
			{
				return kv.first;
			}
		};
	public:
		typedef typename hashbucket::HashTable<K, pair<const K, V>, MapKeyOfT, Hash>::iterator iterator;
		iterator begin()
		{
			return _ht.begin();
		}
		iterator end()
		{
			return _ht.end();
		}

		bool insert(const pair<K, V>& kv)
		{
			return _ht.Insert(kv);
		}
	private:
		hashbucket::HashTable<K, pair<const K, V>, MapKeyOfT, Hash> _ht;
	};
	void TestMap()
	{
		unordered_map<int, int> m;
		int a[] = { 1, 4, 5, 14, 15, 8, 9 ,19 };
		for (auto e : a)
			m.insert({e, e});
		unordered_map<int, int>::iterator it = m.begin();
		while (it != m.end())
		{
			cout << it->first << " : " << it->second << endl;
			++it;
		}
	}
}